package org.stone.project.common.pojo.sysEnum;

import org.stone.project.common.pojo.annotation.MarkEnum;

/**
 * 系统响应编码模板
 */
@MarkEnum("systemCodeEnum")
public enum SystemCodeEnum {
    SUCCESS(200,"成功"),
    UNAUTHORIZED(401,"未授权"),
    FORBIDDEN(403,"访问受限，授权过期"),
    NOT_FOUND(404,"资源，服务未找到"),
    BAD_METHOD(405,"不允许的http方法"),
    ERROR(500,"系统内部错误"),
    CUS_ERROR(999,"自定义异常信息"),
    BIG_FILE_ERR(1901,"上传文件太大，请分片上传"),
    SMALL_FILE_ERR(1902,"上传文件太小，无需分片")
    ;
    private Integer code;
    private String describStr;

    SystemCodeEnum(Integer code, String describStr) {
        this.code = code;
        this.describStr = describStr;
    }


    public Integer getCode() {
        return code;
    }

    public String getDescribStr() {
        return describStr;
    }


    /**
     * 根据code获取实例
     * @param code
     * @return
     */
    public static SystemCodeEnum getInstance(Integer code){
        if (code == null)
            return null;
        for (SystemCodeEnum value : values()) {
            if (value.getCode().equals(code))
                return value;
        }
        return null;
    }
}
